local learn_table = {}
local learn_remove_table = {}


local learn_table_1 = createCombatObject()
setCombatParam(learn_table_1, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(learn_table_1, COMBAT_PARAM_AGGRESSIVE, false)

local learn_area_array_1 = createCombatArea({
{0, 0, 0, 1, 0, 0, 0},
{1, 0, 0, 1, 0, 0, 1},
{0, 0, 0, 1, 0, 0, 0},
{0, 0, 0, 3, 0, 0, 0},
{0, 0, 1, 0, 1, 0, 0},
{0, 1, 0, 0, 0, 1, 0},
{1, 0, 0, 1, 0, 0, 1}
})

setCombatArea(learn_table_1, learn_area_array_1) 
setCombatArea(learn_table_1, learn_area_array_1)

function onTargetItem_1(cid, pos)
	local getPos = pos
	getPos.stackpos = 255
	item = getThingfromPos(getPos)
	if item.itemid ~= 11396 or item.type ~= 10 then
		return true
	end
	if learn_remove_table[cid] == nil then
		learn_remove_table[cid] = {}
	end
	table.insert(learn_remove_table[cid], getPos)
end

setCombatCallback(learn_table_1, CALLBACK_PARAM_TARGETTILE, "onTargetItem_1")


local learn_table_2 = createCombatObject()
setCombatParam(learn_table_2, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(learn_table_2, COMBAT_PARAM_AGGRESSIVE, false)

local learn_area_array_2 = createCombatArea({
{0, 0, 0},
{1, 3, 1},
{0, 1, 0}
})
setCombatArea(learn_table_2, learn_area_array_2) 

function onTargetItem_2(cid, pos)
	local getPos = pos
	getPos.stackpos = 255
	item = getThingfromPos(getPos)
	if item.itemid ~= 2512 then
		return true
	end
	if learn_remove_table[cid] == nil then
		learn_remove_table[cid] = {}
	end
	table.insert(learn_remove_table[cid], getPos)
end

setCombatCallback(learn_table_2, CALLBACK_PARAM_TARGETTILE, "onTargetItem_2")


learn_table[1] = learn_table_1
learn_table[2] = learn_table_2


dofile(getDataDir() .. 'spells/scripts/RPG/learnspells.lua')

function onCastSpell(cid, var)
	doLern(cid, var, 'Magic Shield', 15, learn_remove_table, learn_table, true)
	return false
--	return doLern(cid, var, spell_name, learn_table, __ADDITIONAL__FUNCTION__true)
end